package com.blate.dogxiao.activity;

import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;

import com.blate.dogxiao.R;
import com.blate.dogxiao.bean.UserBean;
import com.blate.dogxiao.databinding.ActivityUserProfileBinding;
import com.bumptech.glide.Glide;

/**
 * @author Blate
 * Created in 2021/4/21
 */
public class UserProfileActivity
        extends AppCompatActivity {

    public static final String KEY_USER_BEAN = "key_user_bean";

    private ActivityUserProfileBinding mBinding;

    private UserBean mUserBean;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mBinding = DataBindingUtil.setContentView(this, R.layout.activity_user_profile);
        readExtra(getIntent());
        initialize();
    }

    private void readExtra(Intent intent) {
        mUserBean = intent.getParcelableExtra(KEY_USER_BEAN);
    }

    private void initialize() {
        mBinding.topBar.setNavigationOnClickListener(v -> finish());
        Glide
                .with(this)
                .load(mUserBean.avatar)
                .into(mBinding.ivAvatar);
        mBinding.tvNickname.setText(mUserBean.nickname);
        mBinding.tvPhoneNumber.setText(mUserBean.phoneNumber);
    }

}
